package com.example.cosplay.scheduler;

import com.example.cosplay.service.WallpaperService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class WallpaperScheduler {

    private final WallpaperService wallpaperService;

    public WallpaperScheduler(WallpaperService wallpaperService) {
        this.wallpaperService = wallpaperService;
    }

    /**
     * Download a new wallpaper every day at midnight
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void scheduledWallpaperDownload() {
        log.info("Starting scheduled wallpaper download");
        String result = wallpaperService.fetchAndDownloadWallpaper();
        log.info("Scheduled download result: {}", result);
    }
} 